package com.saltedfish.tool.util;

import android.os.Build;

import java.util.UUID;

/**
 * Created by Administrator on 2017/6/20 0020.
 */
public class DeviceIDUtils {

    //获得独一无二的Psuedo ID
    public static void getUniquePsuedoID() {
        String serial = null;
        String m_szDevIDShort = android.os.Build.FINGERPRINT +
                Build.BOARD.length() % 10 + Build.BRAND.length() % 10 +
                Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 +
                Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 +
                Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 +
                Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 +
                Build.TAGS.length() % 10 + Build.TYPE.length() % 10 +
                Build.USER.length() % 10; //13 位
        try {
            serial = android.os.Build.class.getField("SERIAL").get(null).toString();
            //API>=9 使用serial号
            SharePreferceUtils.setString("device_id", new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString());
          //  SPUtils.putUserValues(this,"deviceID",new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString());
        } catch (Exception exception) {
            //serial需要一个初始化
            serial = "serial"; // 随便一个初始化
        }

        SharePreferceUtils.setString("device_id", new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString());
        //使用硬件信息拼凑出来的15位号码
     //   SPUtils.putUserValues(this,"deviceID",new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString());
    }



}
